Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
rtc-ai-denoiser
Advanced tools
The RTCAIDenoiser plugin can be used in conjunction with the TRTC Web SDK to reduce noise during calls and reduce the impact of ambient sound on calls.
English | 简体中文
The RTCAIDenoiser plugin can be used in conjunction with the TRTC Web SDK to reduce noise during calls and reduce the impact of ambient sound on calls.
This article describes how to use the RTCAIDenoiser plugin in developing TRTC applications to apply AI noise reduction to streams when publish. Click to experience the noise reduction demo online.
From 1 April 2023, TRTC monthly subscription Premium and higher is required to use the AI noise reduction function.
Supported browsers: Chrome 66+, Edge 79+, Safari 14.1+, Firefox 76+.
For better use of AI noise reduction, it is recommended that you use the latest version of Chrome.
Notes:
If there is background music captured by your microphone, RTCAIDenoiser
may eliminate it as noise.
npm install rtc-ai-denoiser@latest
The RTCAIDenoiser
plugin needs to be installed in the same scope as TRTC
.
import TRTC from 'trtc-js-sdk';
import RTCAIDenoiser from 'rtc-ai-denoiser';
Dynamically loading file dependencies: The RTCAIDenoiser plugin relies on a number of files. To ensure that your browser can load and run these files properly, you need to complete the following steps.
Publish the denoiser-wasm.js
file from the node_modules/rtc-ai-denoiser/assets
directory to a CDN
or static resource server and under the same public path. When creating RTCAIDenoiser
instances later, you need to pass in the URL of the above public path and the plugin will load the dependency files dynamically.
- If the Host URL of the file in the assets directory does not match the Host URL of the web application, you need to enable the CORS policy for accessing the file domain.
- You cannot place assets directory files under an HTTP service, as loading HTTP resources under an HTTPS domain is prohibited by browser security policies.
Reference Quick Start Call to implement a basic audio/video call process.
init RTCAIDenoiser
// Create an instance, passing in the public path where the files in the assets directory are located
const rtcAIDenoiser = new RTCAIDenoiser({ assetsPath: './assets' });
const processor = await rtcAIDenoiser.createProcessor({
sdkAppId,
userId,
userSig
});
// init stream
const localStream = TRTC.createStream({ video: true, audio: true });
await localStream.initialize();
// adding noise suppression to localStream
await processor.process(localStream);
// publish
await client.publish(localStream);
enable
method and the disable
method.if (processor.enabled) {
await processor.disable();
} else {
await processor.enable();
}
startDump
method to start and the stopDump
method to end, and listen to the ondumpend
callback to get the audio and video data.processor.on('ondumpend', ({ blob, name }) => {
const url = window.URL.createObjectURL(blob);
let anchor = document.createElement('a');
anchor.href = url;
anchor.download = `${name}-${Date.now()}.wav`;
anchor.click();
window.URL.revokeObjectURL(url);
anchor.href = '';
});
const rtcAIDenoiser = new RTCAIDenoiser({ assetsPath: './assets' })
Determine whether the current environment supports RTCAIDenoiser.
if (!rtcAIDenoiser.isSupported()) {
console.log('Your browser is not supported RTCAIDenoiser');
}
create denoiserProcessor instance.
const denoiserProcessor = await rtcAIDenoiser.createProcessor({
sdkAppId,
userId,
userSig
});
Params:
Name | Type | Description |
---|---|---|
sdkAppId | number | sdkAppId that your application use |
userId | string | userId that current client use |
userSig | string | userSig signature |
Add noise suppression to the audio of the local stream.
await denoiserProcessor.process(localStream);
Whether AI noise suppression is currently turned on.
const enabled = denoiserProcessor.enabled
Turn on AI noise reduction.
await denoiserProcessor.enable()
Turn off AI noise reduction.
await denoiserProcessor.disable()
Start dumping audio data from the noise reduction process. Up to 30 seconds.
denoiserProcessor.startDump()
Stop dumping audio data from the noise reduction process. Up to 30 seconds.
denoiserProcessor.stopDump()
add event listener to events from the processor.
eg:
After listening to the ondumpend
event, the audio data is dumped and the example code is as follows.
denoiserProcessor.on('ondumpend', ({ blob, name }) => {
const url = window.URL.createObjectURL(blob);
let anchor = document.createElement('a');
anchor.href = url;
anchor.download = `${name}-${Date.now()}.wav`;
anchor.click();
window.URL.revokeObjectURL(url);
anchor.href = '';
});
remove event listener to events from the processor.
Destroy the processor to release resources and end the processor life cycle.
Optimising performance issues.
Optimisation of statistics.
Optimize the error message.
Optimize the destruction logic and reduce memory usage.
Improve the noise reduction effect.
Optimize the authentication strategy.
Optimize the error message.
Released version 1.0.0.
FAQs
AI denoiser plugin for TRTC Web SDK
The npm package rtc-ai-denoiser receives a total of 249 weekly downloads. As such, rtc-ai-denoiser popularity was classified as not popular.
We found that rtc-ai-denoiser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.